//
//  ZZTaskInfoVIew.swift
//  QMXK
//
//  Created by jenkin on 2018/12/12.
//  Copyright © 2018年 jenkin. All rights reserved.
//

import UIKit

class ZZTaskInfoVIew: UIView {

    var openLabel:UILabel!
    var finishLabel:UILabel!
    var maxLabel:UILabel!
    var minLabel:UILabel!
    var timeLabel:UILabel!
    
    var model:ZZTaskModel?
    var taskModel:ZZTaskModel?{
        get{
            return self.model
        }
        set{
            self.model = newValue
            self.setUI()
        }
    }
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        let font:UIFont = CommenConst.shareCommentConst.KNFONT(15)
        self.openLabel = ZZViewUtil.shareViewUtil.createLabel(textAlign: NSTextAlignment.left, text: "", font: font, color: UIColor.white, autoLine: false)
        self.addSubview(self.openLabel!)
        
        self.finishLabel = ZZViewUtil.shareViewUtil.createLabel(textAlign: NSTextAlignment.left, text: "", font: font, color: UIColor.white, autoLine: false)
        self.addSubview(self.finishLabel)
        
        self.maxLabel = ZZViewUtil.shareViewUtil.createLabel(textAlign: NSTextAlignment.left, text: "", font: font, color: UIColor.white, autoLine: false)
        self.addSubview(self.maxLabel)
        
        self.minLabel = ZZViewUtil.shareViewUtil.createLabel(textAlign: NSTextAlignment.left, text: "", font: font, color: UIColor.white, autoLine: false)
        self.addSubview(self.minLabel)
        
        self.timeLabel = ZZViewUtil.shareViewUtil.createLabel(textAlign: NSTextAlignment.left, text: "", font: font, color: UIColor.white, autoLine: false)
        self.addSubview(self.timeLabel)
        
        let labelArray:Array! = [self.openLabel, self.finishLabel, self.maxLabel, self.minLabel, self.timeLabel]
        for index in 0..<5{
            let label:UILabel = labelArray[index] as! UILabel
            label.snp.makeConstraints { (make) in
                make.left.equalTo(0)
                make.height.equalTo(15)
                make.top.equalTo(index * 20)
                make.width.equalTo(200)
            }
        }
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    func setUI(){
        self.openLabel.text =  "open: " + ZZBaseUtil.shareUtil.getStrWithFloat(text: self.taskModel?.open ?? 0)
        self.finishLabel.text =  "finish: " + ZZBaseUtil.shareUtil.getStrWithFloat(text: self.taskModel?.finish ?? 0)
        self.maxLabel.text =  "max: " + ZZBaseUtil.shareUtil.getStrWithFloat(text: self.taskModel?.max ?? 0)
        self.minLabel.text =  "min: " + ZZBaseUtil.shareUtil.getStrWithFloat(text: self.taskModel?.min ?? 0)
        self.timeLabel.text = "time: " + (self.taskModel?.time ?? "0")
    }
    
}
